<template>
  <div class="app-container">
    <h5 class="titleInfo">积分明细</h5>
    <div class="table" v-loading="tableLoading">
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="realname" align="center" label="姓名"></el-table-column>
        <el-table-column prop="amount" align="center" label="积分"></el-table-column>
        <!-- <div v-if="fieldFlag==1"> -->
        <el-table-column v-if="fieldFlag" prop="msg" align="center" label="积分说明"></el-table-column>
        <!-- </div> -->
        <!-- <div v-else> -->
        <el-table-column v-else prop="coinDescription" align="center" label="积分说明">
          <!-- <template slot-scope="scope">
            <p>税款:{{scope.row.feeAmt}}</p>
            <p>实到金额:{{scope.row.amount}}</p>
          </template> -->
        </el-table-column>
        <!-- </div> -->
        <!-- <div v-if="fieldFlag==1"> -->
        <el-table-column v-if="fieldFlag" prop="operatMsg" align="center" label="操作信息"></el-table-column>
        <!-- </div> -->
        <!-- <div v-else> -->
        <el-table-column v-else prop="operationInfo" align="center" label="操作信息"></el-table-column>
        <!-- </div> -->
        <!-- <el-table-column prop="operationInfo" align="center" label="操作信息"></el-table-column> -->
        <el-table-column prop="remark" align="center" label="备注信息"></el-table-column>
        <!-- <div v-if="fieldFlag==1"> -->
        <el-table-column v-if="fieldFlag" prop="createdAt" align="center" label="创建时间"></el-table-column>
        <!-- </div> -->
        <!-- <div v-else> -->
        <el-table-column v-else prop="createTime" align="center" label="创建时间"></el-table-column>
        <!-- </div> -->
        <!-- <el-table-column prop="createTime" align="center" label="创建时间"></el-table-column> -->
      </el-table>
      <div class="block" style="margin: 40px 0;">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="params.pageNum"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="params.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>
<script>
import vipmange from "@/api/vipmange/vipmange";
import { selectIntegralDetails } from "@/api/ServiceManagement";

export default {
  name: "Integraldetails",
  data() {
    return {
      // loading层
      tableLoading: false,
      tableData: [{}],
      params: {
        userId: 0,
        pageSize: 10,
        pageNum: 1,
        amountType:null
      },
      total: 60,
      //不同字段判断开关
      fieldFlag: null
    };
  },
  methods: {
    async list() {
      this.tableLoading = true;

      // if (this.$route.query.type == 1) {
      //   let res = await selectIntegralDetails({ userId: this.params.userId });
      //   console.log(res);
      //   if (!res.data.code) {
      //     this.tableData = res.data.data.list;
      //     this.total = res.data.data.count;
      //   } else {
      //     this.$message({
      //       message: res.data.msg,
      //       type: "warning"
      //     });
      //   }
      // } else {
      //   let res = await vipmange.userlist(this.params);
      //   console.log(res);
      //   if (res.data.code == 0) {
      //     this.tableData = res.data.data.list;
      //     this.total = res.data.data.count;
      //   } else {
      //     this.$message({
      //       message: res.data.msg,
      //       type: "warning"
      //     });
      //   }
      // }

      let res;
      if (this.$route.query.type) {
        this.params.amountType=this.fieldFlag
        res = await selectIntegralDetails(this.params);
        // console.log(res);
      } else {
        this.params.amountType = this.$route.query.amountType - 0;
        res = await vipmange.userlist(this.params);
      }
      console.log(res);
      if (res.data.code == 0) {
        this.tableData = res.data.data.list;
        this.total = res.data.data.count;

        this.tableLoading = false;
      } else {
        this.$message({
          message: res.data.msg,
          type: "warning"
        });
      }
    },
    handleSizeChange(val) {
      this.params.pageNum = 1;
      this.params.pageSize = val;
      this.list();
    },
    handleCurrentChange(val) {
      this.params.pageNum = val;
      this.list();
    }
  },
  mounted() {
    this.fieldFlag = this.$route.query.type;
    this.params.userId = this.$route.query.userId - 0;
    this.list();
  }
};
</script>